#ifndef __THREADPOOL_H_
#define __THREADPOOL_H_

#include "Thread.hpp"
#include "TaskQueue.hpp"
#include <vector>
#include <memory>
#include <functional>

using std::vector;
using std::unique_ptr;
using std::function;

namespace ln{

using Task = std::function<void()>;

class ThreadPool{
public:
    ThreadPool(size_t,size_t);
    ~ThreadPool();
    void start();
    void stop();
    void addTask(Task &&);

private:
    void doTask();

private:
    vector<unique_ptr<Thread>> _threads;
    size_t _threadNum;
    TaskQueue _taskque;
    size_t _queSize;
    bool _isExit;
};

}//end of namespace ln

#endif

